class MCPVersionComparator:
    def __init__(self):
        # 支持的版本列表 按时间顺序排序
        self.supported_versions= ["2023-09-15", "2024-12-01", "2025-06-18"]
    def parse_version(self,version_string): 
        from datetime import datetime
        # strptime可以把日期字符中按对应的具体格式转成datetime对象
        return datetime.strptime(version_string,"%Y-%m-%d")

    def is_compatible(self,client_version,server_version):
        client_date = self.parse_version(client_version)
        server_date = self.parse_version(server_version)
        return client_date == server_date
    def get_latest_common_version(self,client_versions,server_versions):
        # 计算客户端和服务器都支持的版本集合
        common_versions = set(client_versions) & set(server_versions)
        if not common_versions:
            return None
        #找到最新的那个版本
        latest_version = max(common_versions,key=self.parse_version)
        return latest_version

comparator = MCPVersionComparator()
client_version = '2024-12-01'
server_version='2025-06-18'
if comparator.is_compatible(client_version,server_version):
    print(f"版本兼容")
else:
    print(f"版本不兼容")    